﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARUserControls
{
    /// <summary>
    /// OverallStepBar.xaml 的交互逻辑
    /// </summary>
    public partial class OverallStepBar : UserControl
    {
        private int currentStep = 0;
        private TextBlock[] titles;
        private Grid[] reachedPoints;
        private Grid[] unreachedPoints;

        public OverallStepBar()
        {
            this.InitializeComponent();
            titles = new TextBlock[7];
            titles[0] = txtStep1;
            titles[1] = txtStep2;
            titles[2] = txtStep3;
            titles[3] = txtStep4;
            titles[4] = txtStep5;
            titles[5] = txtStep6;
            titles[6] = txtStep7;

            reachedPoints = new Grid[7];
            reachedPoints[0] = reachedPoint1;
            reachedPoints[1] = reachedPoint2;
            reachedPoints[2] = reachedPoint3;
            reachedPoints[3] = reachedPoint4;
            reachedPoints[4] = reachedPoint5;
            reachedPoints[5] = reachedPoint6;
            reachedPoints[6] = reachedPoint7;

            unreachedPoints = new Grid[7];
            unreachedPoints[0] = unreachedPoint1;
            unreachedPoints[1] = unreachedPoint2;
            unreachedPoints[2] = unreachedPoint3;
            unreachedPoints[3] = unreachedPoint4;
            unreachedPoints[4] = unreachedPoint5;
            unreachedPoints[5] = unreachedPoint6;
            unreachedPoints[6] = unreachedPoint7;
        }


        public int SARCurrentStep
        {
            get { return currentStep; }
            set
            {
                if (value > 6)
                {
                    value = 6;
                }
                else if (value < 0)
                {
                    value = 0;
                }
                titles[currentStep].Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0x0d, 0x13));
                
                titles[value].Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x71, 0x8B, 0x15));
                
                for (int i = 0; i < 7; i++)
                {
                    if (i <= value)
                    {
                        reachedPoints[i].Visibility = System.Windows.Visibility.Visible;
                        unreachedPoints[i].Visibility = System.Windows.Visibility.Hidden;
                    }
                    else
                    {
                        reachedPoints[i].Visibility = System.Windows.Visibility.Hidden;
                        unreachedPoints[i].Visibility = System.Windows.Visibility.Visible;
                    }
                }
                greenBar.Width = 25.6 + value * 109;
                decoration.Width = 38 + value * 109;
                stepicon.Margin = new Thickness(16 + value * 109, stepicon.Margin.Top, stepicon.Margin.Right, stepicon.Margin.Bottom);
                currentStep = value;
            }
        }
    }
}